package com.bingo.generate.cli.Cmds;


import com.bingo.generate.comm.entity.ColInfo;

import java.util.List;

/**
 * ClassName    生成sql脚本的命令
 * Description
 * Create by lc
 * Date 2021/7/19 13:37
 */
public class JsCodeCmd {

    //  为了有提示
    public static void getDefaultData(List<ColInfo> cols){
        StringBuilder strBud=new StringBuilder();
        strBud.append("const defaultData = {");
        for (int i = 0; i < cols.size(); i++) {
            ColInfo col=cols.get(i);
            strBud.append("\n\t");
            strBud.append(col.getColName()).append(":''");
            if(i!=cols.size()-1){
                strBud.append(" , ");
            }
            strBud.append("\t\t//\t");
            strBud.append(col.getComment());
        }
        strBud.append("\n}");
        System.out.println(strBud.toString());
    }

    //  为了有提示
    public static void getCla(String className,List<ColInfo> cols){
        StringBuilder strBud=new StringBuilder();
        strBud.append(String.format("export class %s = {",className)).append("\n");
        for (int i = 0; i < cols.size(); i++) {
            ColInfo col=cols.get(i);
            strBud.append("\t//\t"+cols.get(i).getComment()+"\n");
            strBud.append("\t");
            strBud.append(col.getColName()).append("");
            if(i!=cols.size()-1){
                strBud.append("  ");
            }
            //strBud.append("\t\t//\t");
            //strBud.append(col.getComment());
            strBud.append("\n");
        }
        strBud.append("\n}");
        System.out.println(strBud.toString());
    }

}
